<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>找回密码</title>
<link type="text/css" rel="stylesheet" href="css/password.css" />
  <link rel="stylesheet" href="../plugins/elementui/index.css" />
<script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
<script src="js/healthmobile.js"></script>
  <script src="../js/vue.js"></script>
  <script src="../js/axios-0.18.0.js"></script>
  <script src="../plugins/elementui/index.js"></script>
<script type="text/javascript">
$(document).ready(function () {
	var height=$(document).height();
	$('.main').css('height',height);
})
</script>
</head>

<body>
<div class="main" id="app">
  <div class="main0">
     <div class="formBox">
       <h3>登录密码重置</h3>
       <ul>
          <li class="mainCol firLi">&gt;身份验证</li>
          <li class="mainCol">&gt;登录密码重置</li>
          <li class="lastLi">&gt;重置完成</li>
       </ul>
       <img src="images/line2.png" />
       <!--<div class="itembox itembox_2">-->
         <!--<label>手机号码 &nbsp;:</label>-->
         <!--<input type="text" placeholder="请输入手机号码" v-model="loginInfo.telephone">-->
       <!--</div>-->
       <div class="itembox itembox_2">
         <label>用户名 &nbsp;:</label>
         <input type="text" placeholder="请输入用户名" v-model="formData.username">
       </div>
       <div class="itembox itembox_2">
         <label>登录密码&nbsp;:</label>
         <input type="password" placeholder="请输入新登录密码" v-model="loginInfo.password1"></span>
       </div>
       <div class="itembox itembox_2">
         <label>确认密码&nbsp;:</label>
         <input type="password" placeholder="请再次输入新密码" v-model="formData.password"></span>
       </div>
       <!--<div class="itembox itembox_2">
         <label>验证码&nbsp;:</label>
         <input type="text" placeholder="请输入验证码" class="yzm" v-model="loginInfo.validateCode"></span>
       </div>-->
       <div class="btnBox">
            <button @click="changePassword()">下一步</button>
       </div>
     </div>
  </div>
</div>

<script type="text/javascript">

    var vue = new Vue({
            el:'#app',
            data:{
                //验证码信息
                loginInfo:{},
                //修改用户的信息
                formData:{}
            },
        methods:{

            //修改密码
            changePassword(){
                //判断是否输入用户名
                if (this.formData.username==null){
                    this.$message({
                        type:'error',
                        message:"请输入信息",
                        center:true
                    });
                }
                //判断输入密码
                if (this.loginInfo.password1!=null && this.formData.password!=null){
                    //判断用户输入两次的密码是否相同
                    if (this.loginInfo.password1!=this.formData.password){
                        this.$message({
                            type:'error',
                            message:"两次输入密码不相同",
                            center:true
                        });
                    }else {
                        /*//判断验证码是否输入
                        if (this.loginInfo.validateCode==null){
                            this.$message({
                                type:'error',
                                message:"请输入信息",
                                center:true
                            });
                        }*/
                        //发送和请求进行用户信息修改（cff）
                        axios.post("/user/setpassword.do",this.formData).then((response) => {
                            if(response.data.flag){
                                //修改成功,跳转到修改成功界面
                                window.location.href='password_3.html';
                            }else{
                                //失败，提示失败信息
                                this.$message.error("修改失败");
                                window.location.href='../mylogin/index.html';
                            }
                        });
                    }
                } else {
                    this.$message({
                        type:'error',
                        message:"请输入信息",
                        center:true
                    });
                }

            }
        }
    });
</script>
</body>
</html>
